<template>
  <div class="movie-card" @click="movieInfo(movie.id)">
    <div class="movie-poster">
      <img :src="movie.img" :alt="movie.name" />
    </div>
    <div class="movie-details">
      <h2 class="movie-title">
        <span class="main-title">{{ movie.name }}</span>
        <span class="year">({{ movie.date }})</span>
      </h2>
      <p class="movie-meta">类型: {{ movie.type }}</p>
      <p class="movie-meta">国家/地区: {{ movie.nation }}</p>
    </div>
  </div>
</template>

<script setup>

import router from "@/router/index.ts";

defineProps({
  movie: {
    type: Object,
    required: true
  }
});


// 跳转到电影详情页面
function movieInfo(id) {
  console.log('跳转到电影详情页面')
  console.log(id)
  router.push(
    {
      path: '/movieInfo',
      query: { "movie_id": id },
    }
  )
}
</script>

<style scoped>
.movie-card {
  display: flex;
  border-bottom: 1px solid #ddd;
  padding: 20px 0;
  font-family: Arial, sans-serif;
}

.movie-poster img {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border: 1px solid #ddd;
  margin-right: 20px;
}

.movie-details {
  flex: 1;
}

.movie-title {
  font-size: 18px;
  margin: 0 0 10px;
  line-height: 1.5;
}

.movie-title .main-title {
  font-weight: bold;
  color: #ffffff;
  margin-right: 10px;
}

.movie-title .sub-title {
  color: #666;
  margin-right: 10px;
}

.movie-title .year {
  color: #999;
}

.movie-meta {
  margin: 5px 0;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}
</style>
